<template>
  <div>
    <r-search
      :searchForm="searchForm"
      :searchHandle="searchHandle"
      :searchData="searchData"
    />
    <r-table
      :isIndex="true"
      :isPagination="true"
      :tableData="tableData"
      :height="350"
      :tableCols="tableCols"
      :tablePage="tablePage"
      @refresh="init()"
    ></r-table>
  </div>
</template>
<script>
export default {
  props: {
    userid: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      searchData: {
        number: "",
        deviceType: "",
        agent: "",
        saller: "",
        sType: "2"
      },
      searchForm: [
        {
          type: "input",
          prop: "number",
          placeholder: "Order Nnumber",
          width: 150
        },
        {
          type: "date",
          prop: "etime",
          placeholder: "起始时间",
          width: 180
        },
        {
          type: "date",
          prop: "updateEtime",
          placeholder: "End Time",
          width: 180
        }
      ],
      searchHandle: [
        {
          label: "Search",
          type: "success",
          icon: "el-icon-search",
          handle: e => this.init()
        },
        {
          label: "Reset",
          icon: "el-icon-refresh-right",
          handle: e => this.searchFromReset()
        }
      ],
      tableData: [],
      tableCols: [
        {
          label: "Order Nnumber",
          prop: "number"
          // theme: e => e.status ? 'primary' : 'danger', type: "tag",
        },
        {
          label: "Withdrawal Time",
          prop: "createdTime"
        },
        {
          label: "Withdrawal Amount",
          prop: "money"
        },
        {
          label: "审核结果",
          prop: "state",
          formatter: e =>
            e.state == 1
              ? "Review Pass"
              : e.state == 2
              ? "审核不Pass"
              : e.state == 3
              ? "Pending Review"
              : ""
        },
        {
          label: "Audit Time",
          prop: "updatedBy"
        },
        {
          label: "审核人",
          prop: "updatedBy"
        }
      ],
      tablePage: { limit: 10, page: 1, total: 0 }
    };
  },
  components: {},
  computed: {},
  mounted() {
    this.init();
  },
  methods: {
    async init() {
      this.searchData.userId = this.$route.query.id;
      let param = {
        ...this.searchData,
        ...this.tablePage,
        userId: this.$route.query.id
      };
      let res = await this.api.takecashList(param);
      if (res) {
        this.tableData = res.data.list;
      }
    },
    elFormSubmit(e) {
      //查询
      console.log(e);
    },
    elFormDetail(row) {
      Object.keys(this.formData).forEach(key => {
        this.formData[key] = row[key];
      });
      this.formData.id = row.id;
      this.formData.cardId = row.cardId;
      // if (this.formCols[1].label == '登录密码') {
      //     this.formCols.splice(1, 1)
      // }

      this.elFormVisible();
    }
  }
};
</script>
<style scoped lang="scss">
.el-icon-search {
  margin-right: 10px;
}
.Tip {
  margin-left: 20px;
}
</style>
